<template>
	<el-form :model="formData" ref="formRef" :rules="formRules" label-width="8rem">
		<el-row type="flex" :gutter="10">
			<el-col :span="12">
				<el-form-item label="会员昵称" prop="wxName">
					<el-input disabled v-model="formData.wxName"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="订单号" prop="order_sn">
					<el-input disabled v-model="formData.order_sn"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="电话号码" prop="mainPhone">
					<el-input disabled v-model="formData.mainPhone"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="订单总金额" prop="total_money">
					<el-input disabled v-model="formData.total_money"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="运费" prop="freight_money">
					<el-input disabled v-model="formData.freight_money"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="实际支付金额" prop="pay_money">
					<el-input disabled v-model="formData.pay_money"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="下单时间" prop="addtime">
					 <el-date-picker
					     disabled 
						 v-model="formData.addtime"
					      type="date"
					      placeholder="选择日期">
					    </el-date-picker>
					<!-- <el-input disabled v-model="formData.addtime"></el-input> -->
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="支付时间" prop="pay_time">
					<el-date-picker
						 disabled 
						 v-model="formData.pay_time"
						  type="date"
						  placeholder="选择日期">
						</el-date-picker>
					<!-- <el-input disabled v-model="formData.pay_time"></el-input> -->
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="订单状态" prop="status">
					<el-select v-model="formData.status" size="mini" placeholder="请选择订单状态" disabled
						>
						<el-option v-for="item in typelist" :key="item.id" :label="item.label" :value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="支付状态" prop="pay_status">
					<el-select v-model="formData.pay_status" size="mini" placeholder="请选择订单状态" disabled
						>
						<el-option v-for="item in paylist" :key="item.id" :label="item.label" :value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="客户收货地址" prop="province">
					<el-input disabled v-model="formData.province+formData.city+formData.town"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="24">
				<el-form-item label="订单商品">
					<div >
						<div class="goodslist" v-for="(item,index) in formData.goodsList" :key="index">
							<el-image style="width: 80px;height: 80px;margin-right: 10px;" :src="'https://mtang.zxkjnc.com'+item.url"></el-image>
							<div class="info">
								<div>商品名称:{{item.goods_name}}</div>
								<div>商品价格:{{item.goods_price}}</div>
								<div v-if="item.spec_name">商品规格:{{item.spec_name}}</div>
								<div style="display: flex;justify-content: space-between; width: 300px;">
									<div>商品数量:{{item.goods_num}}</div>
									<!-- 0已支付1待退款2已退款 -->
									<div v-if="item.re_status==0">已支付</div>
									<div v-if="item.re_status==1">待退款</div>
									<div v-if="item.re_status==2" style="color: red;">已退款</div>
								</div>
							</div>
						</div>
					</div>
				</el-form-item>
			</el-col>
		</el-row>
		<el-row type="flex" justify="center">
			<el-button type="primary"  @click="onCancel">确认</el-button>
			<!-- <el-button type="default" icon="el-icon-close" @click="onCancel">取消</el-button> -->
		</el-row>
	</el-form>
</template>

<script>
	import {
		get
	} from "@/assets/js/http.js";
	export default {
		name: "member-search",
		props: {
			id: {
				type: String,
				default: () => ''
			},
		},
		components: {
			// "el-upload-image": () => import("@/components/el-upload-image.vue"),
		},
		mounted() {
			console.log(this.formData,'formData')
			this.getinfo(this.id)
		},
		data() {
			return {
				formRules: {
					img: [{
						required: true,
						message: '请输入',
						trigger: 'change'
					}],
				},
				formData:{},
				typelist: [{
					id: 0,
					label: '待付款'
				}, {
					id: 1,
					label: '待发货'
				}, {
					id: 2,
					label: '待收货'
				}, {
					id: 3,
					label: '待评价'
				}, {
					id: 4,
					label: '已取消'
				}, {
					id: 5,
					label: '售后退款中'
				}, {
					id: 6,
					label: '已完成'
				}, {
					id: 7,
					label: '售后完成'
				}], //0待付款 1待发货 2待收货 3待评价 4已取消 5售后退款中 6已完成 7售后完成
				paylist: [{
					id: 0,
					label: '未支付'
				}, {
					id: 1,
					label: '已支付'
				}], // 0未支付 1已支付
			};
		},
		methods: {
			getinfo(){
				get({
					url: '/admin/order.Order/edit',
					params: {
						id: this.id
					}
				}).then(res => {
					// this.formData={}
					console.log(res.row,'res.row')
					this.formData = res.row
					this.formData.addtime = this.formData.addtime*1000
					this.formData.pay_time = this.formData.pay_time*1000
				})
			},
			onConfirm() {
				this.$refs.formRef.validate((valid) => {
					if (valid) {
						// alert('submit!');
						console.log(this.formData)
						this.$emit("search", this.formData);
						this.$parent.$emit("update:visible", false);
						this.$refs.formRef.resetFields()
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			onCancel() {
				this.$parent.$emit("update:visible", false);
				this.$refs.formRef.resetFields();
			}
		}
	};
</script>

<style lang="scss" scoped>
	.goodslist{
		display: flex;
		align-items: center;
	}
</style>
